#!/usr/bin/env bash

mkdir -p /usr/local/shardingproxy/{conf,ext-lib,logs} \
&& rm -rf /usr/local/shardingproxy/logs/* \
&& chmod -R 777 /usr/local/shardingproxy/logs \
&& cd /usr/local/shardingproxy/ext-lib \
&& wget https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.3.0/mysql-connector-j-8.3.0.jar \
&& chmod 777 mysql-connector-j-8.3.0.jar

docker run -d \
--name shardingproxy \
--restart=always \
-v /usr/local/shardingproxy/conf:/opt/shardingsphere-proxy/conf \
-v /usr/local/shardingproxy/ext-lib:/opt/shardingsphere-proxy/ext-lib \
-e PORT=3306 \
-p 3309:3306 \
edwin1987/shardingsphere-proxy

mysql -uroot -P3309 -p'Hisense_2024' -h10.196.210.235 -e "use sharding;select * from device_warehouse___16 where device_id = '8650401000100010040000000e4eeeeeeeee'"
mysql -uroot -P3309 -p'Hisense_2024' -h10.196.210.235 -e "use sharding;update device_warehouse___16 set status = 1 where device_id = '8650401000100010040000000e4eeeeeeeee'"

